require 'test/helper'

class TC_Property_class < Test::Unit::TestCase

  # We need a setup so that 
  # we don't step on the foot of other tests
  # I.e. Property.all is empty at start
  def setup
    Property.reset_properties
  end
  # Class tests
  def test_exists
    ok  Property
  end

  def test_has_default_attempts_number
    assert_equal 500, Property.default_attempts_number
  end

  def test_has_mutable_default_attempts_number
    n=50
    assert_equal n, Property.default_attempts_number=n
    assert_equal n, Property.default_attempts_number
    # reset the value
    assert_equal 500, Property.default_attempts_number=500
  end

  def test_all_empty
    assert_equal 0, Property.all.size
  end

  def test_all_props

    # we don't want to write check explicitly all the time
    Property.new('1th', Int) { ok }
    Property.new('2nd', Int) { ok }
    props = Property.all
    assert_equal 2, props.size
    ok props.find {|p| p.description == '1th'}
    ok props.find {|p| p.description == '2nd'}
  end


end
